HomeController = BaseController.extend({
	template:'merchantHome',
	left: '<span></span>',
	center:'商家首页',
	mainView: 'merchantHome',
	bottomShow: true,

	waitOn:function(){
		let self = this;
		Tracker.autorun(function(){
            self.merchantInfo = self.currentUser();
			if (self.merchantInfo) {
				let selector = {merchant_id: parseInt(self.merchantInfo.id)};
				
				Meteor.subscribe('wallets', selector, {});
				Meteor.subscribe('goods', selector, {limit: 2});						
				Meteor.subscribe('orders', {state:'pay', merchant_id: parseInt(self.merchantInfo.id)}, {limit: 2});
				Meteor.subscribe('capitals', {type:'draw', merchant_id: parseInt(self.merchantInfo.id)}, {limit: 2});
			}
        });
	},
	onRendered:function(){

	},
	data: function() {
		return {
			merchant: function(){
				return Merchants.findOne();
			},
			wallet: function(){
				return Wallets.findOne();
			},
			goodsList: function(){
				return Goods.find().fetch();
			},
			orderList: function(){
				return Orders.find().fetch();
			},
			capitalList: function(){
				return Capitals.find().fetch();
			},
		};
	}
})